﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link rel="stylesheet" type="text/css" href="~/Content/MasterPageCSS.css" />
</head>
<body>
    <div class="home_top">
        <div class="TouXiang"></div>
        <div class="HuanYing">
            @if (Session["name"] == null)
            {
                <a href="~/MyHome/entryPage">请登录</a>
            }
            else { 
                <span>欢迎回来 </span><span style="color: red;">@Session["name"].ToString()</span>
            }

        </div>
        <div class="XuanXiang">
            @if (Session["name"] != null) { 
                <div class="QieHuan"><a href="javascript:;">切换账号</a></div>
                <div class="DengChu"><a href="javascript:;">登出</a></div>
            }
        </div>
    </div>
    <div class="Top_TiShi_DengChu">
        <img src="/Image/右上角花纹.png" class="YouShang" />
        <div class="XianTiao_Wei1"></div>
        <div class="XianTiao_Wei2"></div>
        <div class="XianTiao_Wei3"></div>
        <div class="XianTiao_Yi_You"></div>
        <div class="XianTiao_Yi_Xia"></div>
        <div class="XianTiao_Yi_Zuo"></div>
        <div class="XianTiao_Yi_Shang"></div>
        <div class="ZheGai1"></div>
        <div class="DengChu_TiShi">您确定要登出吗?</div>
        <div class="DengChu_but_Yes"><span>确定</span></div>
        <div class="DengChu_but_No"><span>不</span></div>
    </div>
    <div class="Top_TiShi_QieHuan">
        <div class="QieHuan_TextBox">
            <input type="text" class="QieHuan_User" />
            <span class="QieHuan_User_TiShi"></span>
            <input type="text" class="QieHuan_Pwd" />
            <span class="QieHuan_Pwd_TiShi"></span>
            <img src="~/Image/左下角花纹.png" />
            <div class="QieHuan_but_Yes"><span>确定</span></div>
            <div class="QieHuan_but_No"><span>不</span></div>
        </div>
        <div class="QieHuan_BeiJing_wei1"></div>
        <div class="QieHuan_XiaoTiao_Wei1"></div>
        <div class="QieHuan_XiaoTiao_Wei2"></div>
        <div class="QieHuan_XiaoTiao_Wei3"></div>
        <div class="QieHuan_XiaoTiao_Wei4"></div>
        <div class="QieHuan_XiaoTiao_Zuo"></div>
        <div class="QieHuan_XiaoTiao_Top"></div>
        <div class="QieHuan_XiaoTiao_You"></div>
        <div class="QieHuan_XiaoTiao_Xia"></div>
    </div>
    @if(Session["name"] != null)
    {
        <div class="home_left">
            <div class="list-sidebar">
                <ul class="list-sidebar-ul">
                    <li>
                        <div><img src="/Image/personalData.png" /></div>
                        <span>个人资料</span>
                    </li>
                    <li>
                        <div><img src="/Image/personalData.png" /></div>
                        <span>修改密码</span>
                    </li>
                    <li>
                        <div><img src="/Image/personalData.png" /></div>
                        <span>个人资料</span>
                    </li>
                </ul>
            </div>
        </div>
    }
    <div class="home_page">
        @RenderBody()
    </div>
    <script src="~/Scripts/jquery-3.4.1.js"></script>
    <script src="~/Scripts/MasterPageJS.js"></script>
    <script>
        $(function () {
            
            //密码掩盖
            var Pwd_YanGai = function (pwd) {
                var a = "";
                for (var i = 0; i < pwd.length; i++) {
                    a = a + "*";
                }
                $(".QieHuan_Pwd").val(a);
            }
            //密码框消失焦点
            var pwd = "";
            $(".QieHuan_Pwd").focus(function () {
                if ($(".QieHuan_Pwd").val() != "UserPwd") {
                    $(".QieHuan_Pwd").val(pwd);
                }
            }).blur(function () {
                //掩盖
                pwd = $(".QieHuan_Pwd").val();
                Pwd_YanGai(pwd);
                if ($(".QieHuan_Pwd").val() == "") {
                    $(".QieHuan_Pwd").toggleClass("Color_Hei Color_Hui");
                    $(".QieHuan_Pwd").val("UserPwd");
                }
            })
            //登出
            $(".DengChu_but_Yes").click(function () {
                location.href = "KonghomePage";
            })
            //切换账号
            $(".QieHuan_but_Yes").click(function () {
                //判断登录要求
                if ($(".QieHuan_Pwd").val() != "" && $(".QieHuan_User").val() != "") {
                    var number = $(".QieHuan_User").val();
                    if (!((isNaN(number) == true && number != "UserNumber"))) {
                         //账号
                         var userNumber = $(".QieHuan_User").val();
                        //密码
                        var userPwd = pwd;
                        //此处是ajax登录
                        $.post("@Url.Action("register","MyHome")", { number: userNumber, pwd: userPwd }, function (data) {
                            console.log("已接收");
                            if (data.State == 1) {
                                $(".QieHuan_Pwd_TiShi").text(data.Message);
                                console.log(data.Message);
                            }
                            if (data.State == 0) {
                                console.log(data.Message);
                                location.href = data.skipPage;
                            }
                        })
                    }
                }
            })
            //侧边栏功能跳转
            var time;
            $(".list-sidebar-ul").delegate("li", "mouseenter", function () {
                time = $(this).children("span").animate({
                    marginLeft: 10
                }, 200)
            }).delegate("li", "mouseleave", function () {
                time.stop(true);
                $(this).children("span").animate({
                    marginLeft: -50
                }, 500)
            }).delegate("li", "click", function () {
                //此处是ajax返回指定网页地址
                var BiaoQian = $(this).children("span").text();
                $.post("@Url.Action("sidebar", "MyHome")", { name: BiaoQian }, function (data) {
                    location.href = data.skipPage;
                });
            })
        })
    </script>
</body>
</html>
